﻿using System;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Text;

namespace AspNetCoreMini
{
    public class HttpListenerFeature : IHttpRequest, IHttpResponse
    {
        private readonly HttpListenerContext _context;
        public HttpListenerFeature(HttpListenerContext context) => _context = context;

        Uri IHttpRequest.Url => _context.Request.Url;
        NameValueCollection IHttpRequest.Headers => _context.Request.Headers;
        NameValueCollection IHttpResponse.Headers => _context.Response.Headers;
        Stream IHttpRequest.Body => _context.Request.InputStream;
        string IHttpRequest.Method => _context.Request.HttpMethod;
        public Encoding ContentEncoding => _context.Request.ContentEncoding;
        Stream IHttpResponse.Body => _context.Response.OutputStream;
        int IHttpResponse.StatusCode { get => _context.Response.StatusCode; set => _context.Response.StatusCode = value; }
    }
}